package com.spukmk3me.impl.libgdx;

import java.io.IOException;

import com.badlogic.gdx.Gdx;
import com.spukmk3me.debug.Logger;
import com.spukmk3me.io.FileHandle;
import com.spukmk3me.sound.Sound;

final class LibgdxSound extends Sound
{
    @Override
    protected int _load() throws IOException
    {
        FileHandle file = getFileHandle();
        
        /* $if SPUKMK3ME_DEBUG$ */
        Logger.log( "Loading sound " + file.getPath() + "..." );
        /* $endif$ */
        
        m_gdxSound = Gdx.audio.newSound( ((LibgdxFileHandle)file).m_handle );
        
        /* $if SPUKMK3ME_DEBUG$ */
        Logger.log( "done\n" );
        /* $endif$ */
        
        return 0;
    }
    
    com.badlogic.gdx.audio.Sound getSound()
    {
        return m_gdxSound;
    }
    
    @Override
    protected void _release()
    {
        m_gdxSound.dispose();
        m_gdxSound = null;
    }
    
    private com.badlogic.gdx.audio.Sound m_gdxSound;
}
